use strict;
use DB_File;
package ACM;
my $ACM_file="ACM.db";
my %access;

sub check {
	my $gid = shift;
	my $obj = shift;
	
	tie(%access, "DB_File", $ACM_file) or die "Couldn't open ACM file";
	if(defined($access{$gid."|".$obj})){
		return 1;
	} else {
		return 0;
	}
	untie(%access);
}

sub dump {
	my $gid;
	my $obj;
	tie(%access, "DB_File", $ACM_file) or die "Couldn't open ACM file";
	foreach my $r (keys(%access)) {
		($gid, $obj) = split(/\|/, $r);
		
		print "$gid has access to $obj\n";
	}
	untie(%access);
}

sub grant {
	my $gid = shift;
	my $obj = shift;
	
	tie(%access, "DB_File", $ACM_file) or die "Couldn't open ACM file";
	$access{$gid."|".$obj} = "yes!";
	untie(%access);
}
1;
